package cn.sundat.service;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Transactional;

import cn.sundat.dao.CompanyDao;
import cn.sundat.model.Company;
import cn.sundat.model.CompanyProduct;
import cn.sundat.model.PageBean;
import cn.sundat.model.Product;

@Transactional
public class CompnayServiceImpl implements CompanyService {

	@Resource(name="companyDao")
	private CompanyDao companyDao;
	
	@Override
	public List<Company> findAll() {
		return companyDao.findAll();
	}
	
	@Override
	public void save(Company company) {
		companyDao.save(company);
	}
	
	@Override
	public void delete(Company company) {
		companyDao.delete(company);
	}
	
	@Override
	public void update(Company company) {
		companyDao.update(company);
	}

	@Override
	public PageBean<Company> findByPage(Integer currPage, Integer pageSize) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Company.class);
		criteria.addOrder(Order.desc("comp_time"));
		return companyDao.findByPage(currPage, pageSize, criteria);
	}

	@Override
	public Company getById(String comp_id) {
		Company company = companyDao.getById(comp_id);
		return company;
	}
	

	
	
}
